package project_temple.utilityserver;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author STARTHERE
 */
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class WeatherModel1 implements Serializable
{
        private static final long serialVersionUID = 3836336917331587164L;

        private String humidity;
        private String temperature;
        private String condition;
        private String wind;

        private List<WeatherModel1> forecast;

        public WeatherModel1()
        {
                this.forecast = new ArrayList<WeatherModel1>();
        }

        public WeatherModel1(String humidity, String temperature, String condition)
        {
                this.humidity = humidity;
                this.temperature = temperature;
                this.condition = condition;
                this.forecast = new ArrayList<WeatherModel1>();
        }

        public String getHumidity()
        {
                return this.humidity;
        }

        public void setHumidity(String humidity)
        {
                this.humidity = humidity;
        }

        public String getTemperature()
        {
                return temperature;
        }

        public void setTemperature(String temperature)
        {
                this.temperature = temperature;
        }

        public String getCondition()
        {
                return condition;
        }

        public void setCondition(String condition)
        {
                this.condition = condition;
        }

        public String getWind()
        {
                return this.wind;
        }

        public void setWind(String wind)
        {
                this.wind = Utilities.convertWindInformation(wind).getCode();
        }

        public void setWind(WindDirection windDirection)
        {
                this.wind = windDirection.getCode();
        }

        public List<WeatherModel1> getForecast()
        {
                return this.forecast;
        }

        public void setForecast(List<WeatherModel1> forecast)
        {
                if (forecast != null)
                {
                        this.forecast = forecast;
                }
        }

        public void addForecastModel(WeatherModel1 forecastModel)
        {
                if (forecastModel != null)
                {
                        forecast.add(forecastModel);
                }
        }

        @Override
        public String toString()
        {
                return prepareToTring();
        }

        private String prepareToTring()
        {
                StringBuffer sb = new StringBuffer();
                if (this.humidity != null && !this.humidity.equals(""))
                {
                        sb.append("humidity="+ this.humidity + ", ");
                }
                if (this.temperature != null && !this.temperature.equals(""))
                {
                        sb.append("temperature="+ this.temperature + ", ");
                }
                if (this.condition != null && !this.condition.equals(""))
                {
                        sb.append("condition="+ this.condition + ", ");
                }
                if (this.wind != null && !this.wind.equals(""))
                {
                        sb.append("wind="+ this.wind + ", ");
                }
                if (forecast.size() != 0)
                {
                        sb.append("\nForecast for "+ forecast.size() + " days: \n");
                        for (WeatherModel1 model : forecast)
                        {
                                sb.append(model + "\n");
                        }
                }
                return sb.toString();
        }

}
